package leetcode.jianzhioffer;

/**
 * @program: datastructureandalogorithm
 * @description:
 * @author: hmx
 * @create: 2021-10-28 15:01
 **/
public class JianZhiOffer11 {

    public int minArray(int[] numbers) {
        int index = numbers.length - 1;
        while (index > 0) {
            if (numbers[index] < numbers[index - 1]) {
                return numbers[index];
            }
            index--;
        }
        return numbers[0];
    }

    /*public int minArray(int[] numbers) {
        int low = 0;
        int high = numbers.length - 1;
        while (low < high) {
            int avg = low + high >> 1;
            if (numbers[avg] < numbers[high]) {
                high = avg;
            } else if (numbers[avg] > numbers[high]) {
                low = avg + 1;
            } else {
                high--;
            }
        }
        return numbers[low];
    }*/
}
